home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / token.cc < prev    next >
C/C++ Source or Header  |  1996-03-03  |  2KB  |  149 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if defined (__GNUG__)
  24. #pragma implementation
  25. #endif
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include <config.h>
  29. #endif
  30.  
  31. #include <cassert>
  32.  
  33. #include "error.h"
  34. #include "symtab.h"
  35. #include "token.h"
  36. #include "utils.h"
  37.  
  38. token::token (int l, int c)
  39. {
  40.   line_num = l;
  41.   column_num = c;
  42.   type_tag = generic_token;
  43. }
  44.  
  45. token::token (const string& s, int l, int c)
  46. {
  47.   line_num = l;
  48.   column_num = c;
  49.   type_tag = string_token;
  50.   str = new string (s);
  51. }
  52.  
  53. token::token (double d, const string& s, int l, int c)
  54. {
  55.   line_num = l;
  56.   column_num = c;
  57.   type_tag = double_token;
  58.   num = d;
  59.   orig_text = s;
  60. }
  61.  
  62. token::token (end_tok_type t, int l, int c)
  63. {
  64.   line_num = l;
  65.   column_num = c;
  66.   type_tag = ettype_token;
  67.   et = t;
  68. }
  69.  
  70. token::token (plot_tok_type t, int l, int c)
  71. {
  72.   line_num = l;
  73.   column_num = c;
  74.   type_tag = pttype_token;
  75.   pt = t;
  76. }
  77.  
  78. token::token (symbol_record *s, int l, int c)
  79. {
  80.   line_num = l;
  81.   column_num = c;
  82.   type_tag = sym_rec_token;
  83.   sr = s;
  84. }
  85.  
  86. token::~token (void)
  87. {
  88.   if (type_tag == string_token)
  89.     delete str;
  90. }
  91.  
  92. string
  93. token::text (void)
  94. {
  95.   assert (type_tag == string_token);
  96.   return *str;
  97. }
  98.  
  99. double
  100. token::number (void)
  101. {
  102.   assert (type_tag == double_token);
  103.   return num;
  104. }
  105.  
  106. token::end_tok_type
  107. token::ettype (void)
  108. {
  109.   assert (type_tag == ettype_token);
  110.   return et;
  111. }
  112.  
  113. token::plot_tok_type
  114. token::pttype (void)
  115. {
  116.   assert (type_tag == pttype_token);
  117.   return pt;
  118. }
  119.  
  120. symbol_record *
  121. token::sym_rec (void)
  122. {
  123.   assert (type_tag == sym_rec_token);
  124.   return sr;
  125. }
  126.  
  127. string
  128. token::text_rep (void)
  129. {
  130.   return orig_text;
  131. }
  132.  
  133. token::token (const token& /* tok */)
  134. {
  135.   panic_impossible ();
  136. }
  137.  
  138. token&
  139. token::operator = (const token& /* tok */)
  140. {
  141.   panic_impossible ();
  142. }
  143.  
  144. /*
  145. ;;; Local Variables: ***
  146. ;;; mode: C++ ***
  147. ;;; End: ***
  148. */
  149.